﻿<!--
	========================================================================
	 NQ Software Development Kit Component
	
	 Homepage: http://www.awzhome.de/
	========================================================================
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of NQ Software Development Kit Component.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	========================================================================
-->
	
<UserControl x:Class="AWZhome.NQsdk.Visual.ComponentServiceInformation"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:nqcs="clr-namespace:AWZhome.NQ.CommonServices;assembly=NQCommServ.Interface"
	xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
	xmlns:nqsdk="clr-namespace:AWZhome.NQsdk.Services"
	xmlns:nqsdkhelpers="clr-namespace:AWZhome.NQsdk.Helpers"
	Background="{x:Static SystemColors.ControlBrush}">
	
	<UserControl.Resources>
		<!-- Icon style -->
		<Style x:Key="ItemImageStyle" TargetType="{x:Type Image}">
			<Style.Triggers>
				<!-- Non substituted multi-instance service -->
				<MultiDataTrigger>
					<MultiDataTrigger.Conditions>
						<Condition Binding="{Binding IsSubstituted}" Value="False" />
						<Condition Binding="{Binding IsSingleInstance}" Value="False" />
					</MultiDataTrigger.Conditions>
					<Setter Property="Source" Value="{nqcs:ResourceBinding Component=NQsdkImages, Name=/Images/Service.png, Type=ImageSource}" />
				</MultiDataTrigger>
				<!-- Substituted multi-instance service -->
				<MultiDataTrigger>
					<MultiDataTrigger.Conditions>
						<Condition Binding="{Binding IsSubstituted}" Value="True" />
						<Condition Binding="{Binding IsSingleInstance}" Value="False" />
					</MultiDataTrigger.Conditions>
					<Setter Property="Source" Value="{nqcs:ResourceBinding Component=NQsdkImages, Name=/Images/ServiceSubstituted.png, Type=ImageSource}" />
				</MultiDataTrigger>
				<!-- Non-substituted single-instance service -->
				<MultiDataTrigger>
					<MultiDataTrigger.Conditions>
						<Condition Binding="{Binding IsSubstituted}" Value="False" />
						<Condition Binding="{Binding IsSingleInstance}" Value="True" />
					</MultiDataTrigger.Conditions>
					<Setter Property="Source" Value="{nqcs:ResourceBinding Component=NQsdkImages, Name=/Images/ServiceSingle.png, Type=ImageSource}" />
				</MultiDataTrigger>
				<!-- Substituted single-instance service -->
				<MultiDataTrigger>
					<MultiDataTrigger.Conditions>
						<Condition Binding="{Binding IsSubstituted}" Value="True" />
						<Condition Binding="{Binding IsSingleInstance}" Value="True" />
					</MultiDataTrigger.Conditions>
					<Setter Property="Source" Value="{nqcs:ResourceBinding Component=NQsdkImages, Name=/Images/ServiceSingleSubstituted.png, Type=ImageSource}" />
				</MultiDataTrigger>
			</Style.Triggers>
		</Style>
		
		<!-- DataTemplate for substituted services ListView items -->
		<CollectionViewSource x:Key="SubstitutedSortedDataSource">
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>

		<DataTemplate x:Key="SubstitutedDataTemplate">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="20" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<Image Grid.Column="0" Height="16" Width="16"
					   Style="{DynamicResource ItemImageStyle}" />
				<TextBlock Grid.Column="1" Text="{Binding Path=ServiceInfo.ServiceInterface.Name}" />
			</Grid>
		</DataTemplate>

		<!-- DataTemplate for substituted services ListView items -->
		<CollectionViewSource x:Key="AttachListsSortedDataSource">
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>

		<DataTemplate x:Key="AttachListsDataTemplate">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="20" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<Image Grid.Column="0" Height="16" Width="16"
					   Source="{nqcs:ResourceBinding Component=NQsdkImages, Name=/Images/AttachList.png, Type=ImageSource}"/>
				<TextBlock Grid.Column="1" Text="{Binding}" />
			</Grid>
		</DataTemplate>
		
		<!-- DataTemplate for interface ListView items -->
		<CollectionViewSource x:Key="InterfaceSortedDataSource">
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="FullName" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>

		<DataTemplate x:Key="InterfaceDataTemplate">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="20" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<Image Grid.Column="0" Height="16" Width="16"
					   Source="{nqcs:ResourceBinding Component=NQsdkImages, Name=/Images/Interface.png, Type=ImageSource}" />
				<TextBlock Grid.Column="1" Text="{Binding}" />
			</Grid>
		</DataTemplate>
	</UserControl.Resources>
	
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="220" />
			<RowDefinition Height="5" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<Grid Name="ComponentInfoGrid" Margin="0,0,0,6">
			<Label Height="28" Margin="45,22,29,0" VerticalAlignment="Top"
					   FontSize="12" FontWeight="Bold"
					   Content="{Binding Name}" />
			<TextBlock FontWeight="Bold" Height="20" HorizontalAlignment="Left" Margin="10,75,0,0"
						   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.Name}" VerticalAlignment="Top" Width="113.657" />
			<TextBlock Height="20" Margin="169,75,14,0"
						   Text="{Binding Path=ComponentInfo.DisplayName}" VerticalAlignment="Top" />

			<TextBlock FontWeight="Bold" HorizontalAlignment="Left" Margin="10,101,0,0"
						   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.Version}" Width="123.11" Height="20" VerticalAlignment="Top" />
			<TextBlock Margin="169,101,14,0"
						   Text="{Binding Path=ComponentInfo.DisplayVersion}" Height="20" VerticalAlignment="Top" />

			<TextBlock FontWeight="Bold" HorizontalAlignment="Left" Margin="9.48,126,0,0"
						   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.Copyright}" Width="135.59" Height="19" VerticalAlignment="Top" />
			<TextBlock Margin="169,127,14,0"
						   Text="{Binding Path=ComponentInfo.Copyright}" Height="18" VerticalAlignment="Top" />

			<TextBlock FontWeight="Bold" Margin="10,150,0,0"
						   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.File}" Height="24" VerticalAlignment="Top" HorizontalAlignment="Left" Width="157" />
			<TextBox Margin="169,151,14,0"
						 Text="{Binding Path=ComponentInfo.MainAssembly.Location, Mode=OneWay}"
						 TextWrapping="Wrap" IsReadOnly="True" VerticalScrollBarVisibility="Auto"
						 Background="{x:Static SystemColors.ControlBrush}" Height="59" VerticalAlignment="Top" />
		</Grid>

		<Line Stroke="Black" StrokeThickness="1" Grid.Row="1" X1="0" X2="6000" HorizontalAlignment="Center" />

		<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
			<Grid Name="ServiceInfoGrid" MinHeight="250">
				<Label Height="28" Margin="45,14,29,0" VerticalAlignment="Top"
					   FontSize="12" FontWeight="Bold"
					   Content="{Binding Path=ServiceInfo.ServiceInterface.FullName}" />

				<UniformGrid Margin="6,56,6,6" Rows="2" Columns="2">
					<Grid>
						<!-- Single- or multi-instance service? -->
						<TextBlock Height="27.556" Margin="9.48,17,0,0" VerticalAlignment="Top" FontWeight="Bold"
								   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.ServiceType}"
								   HorizontalAlignment="Left" Width="152" />
						<TextBlock Height="27.556" Margin="200,17,0,0"
								   VerticalAlignment="Top" HorizontalAlignment="Left" Width="147.478">
							   <TextBlock.Style>
								   <Style>
									   <Style.Triggers>
										   <DataTrigger Binding="{Binding Path=ServiceInfo.SingleInstance}" Value="True">
											   <Setter Property="TextBlock.Text" Value="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.ServiceType.Single}" />
										   </DataTrigger>
										   <DataTrigger Binding="{Binding Path=ServiceInfo.SingleInstance}" Value="False">
											   <Setter Property="TextBlock.Text" Value="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.ServiceType.Multi}" />
										   </DataTrigger>
									   </Style.Triggers>
								   </Style>
							   </TextBlock.Style>
						</TextBlock>

						<!-- Service category -->
						<TextBlock Height="27.556" Margin="9.48,45,0,0" VerticalAlignment="Top" FontWeight="Bold"
								   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.ServiceCategory}"
								   HorizontalAlignment="Left" Width="152" />
						<TextBlock Height="27.556" Margin="200,45,0,0"
									   VerticalAlignment="Top" HorizontalAlignment="Left" Width="147.478"
									   Text="{Binding Path=ServiceInfo.ServiceCategory}" />

						<!-- Service is invokable? -->
						<TextBlock Height="27.556" Margin="9.48,73,0,0" VerticalAlignment="Top" FontWeight="Bold"
								   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.IsInvokable}"
								   HorizontalAlignment="Left" Width="152" />
						<TextBlock Height="27.556" Margin="200,73,0,0"
								   VerticalAlignment="Top" HorizontalAlignment="Left" Width="147.478">
							   <TextBlock.Style>
								   <Style>
									   <Style.Triggers>
										   <DataTrigger Binding="{Binding Path=ServiceInfo.IsInvokable}" Value="True">
											   <Setter Property="TextBlock.Text" Value="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.IsInvokable.Yes}" />
										   </DataTrigger>
										   <DataTrigger Binding="{Binding Path=ServiceInfo.IsInvokable}" Value="False">
											   <Setter Property="TextBlock.Text" Value="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.IsInvokable.No}" />
										   </DataTrigger>
									   </Style.Triggers>
								   </Style>
							   </TextBlock.Style>
						</TextBlock>
					</Grid>

					<Grid>
						<TextBlock Height="27.556" Margin="6,7,8,0"
								   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.Substitutes}"
								   VerticalAlignment="Top" />
						<ListBox Margin="6,29,6,6" Name="SubstitutesListBox"
								 ItemsSource="{Binding Source={StaticResource SubstitutedSortedDataSource}}"
								 ItemTemplate="{StaticResource SubstitutedDataTemplate}" />
					</Grid>

					<Grid>
						<TextBlock Margin="9.48,6,6,11" Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.Interfaces}" />
						<ListBox Margin="9.48,30,6,6" Name="InterfaceListBox"
								 ItemsSource="{Binding Source={StaticResource InterfaceSortedDataSource}}"
								 ItemTemplate="{StaticResource InterfaceDataTemplate}" />
					</Grid>

					<Grid>
						<TextBlock Margin="6,6,8,11"
								   Text="{nqcs:ResourceBinding Component=NQsdk, Name=ServiceBrowserView.AttachLists}" />
						<ListBox Margin="6,30,6,6" Name="AttachListsListBox" ItemTemplate="{StaticResource AttachListsDataTemplate}"
								 ItemsSource="{Binding Source={StaticResource AttachListsSortedDataSource}}" />
					</Grid>
				</UniformGrid>
			</Grid>
		</ScrollViewer>
	</Grid>
</UserControl>
